package dmxGroupControl.listeners;

import java.util.ArrayList;
import java.util.Iterator;

public class MappingCollection implements Iterable<Mapping>
{
	ArrayList<Mapping> mappings;
	
	public MappingCollection()
	{
		mappings = new ArrayList<>();
	}
	
	public void Add(Mapping mapping)
	{
		mappings.add(mapping);
	}
	
	public boolean HasMatchFor(Object match)
	{
		return GetMatchFor(match) != null;
	}
	
	public Mapping GetMatchFor(Object match)
	{
		for(Mapping mapping : mappings)
		{
			if(mapping.Matches(match))
			{
				return mapping;
			}
		}
		return null;
	}
	
		
	@Override
	public Iterator<Mapping> iterator()
	{
		return mappings.iterator();
	}

}
